/**
 * 
 */
package com.designpattern.design.factory.nofactory.order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import com.designpattern.design.factory.nofactory.CheesePizza;
import com.designpattern.design.factory.nofactory.GreekPizza;
import com.designpattern.design.factory.nofactory.Pizza;

/**
 * @author zhangyang
 *
 */
public class PizzaOrder {
	// pizza对象
	Pizza pizza;
	// pizza种类
	String pizzaType;

	// 类构造器
	public PizzaOrder() {
		do {
			pizza = null;
			pizzaType = getType();
			if ("greek".equals(pizzaType)) {
				pizza = new GreekPizza();
				pizza.setName("希腊披萨");
			} else if ("cheese".equals(pizzaType)) {
				pizza = new CheesePizza();
				pizza.setName("cheese披萨");
			}else {
				break;
			}
			// 输出制作过程
			pizza.prepare();
			pizza.bake();
			pizza.cut();
			pizza.box();
		} while (true);
	}

	// 写一个方法，可以获取客户希望订购的披萨种类
	private String getType() {
		try {
			BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("input pizza 种类:");
			String str = strin.readLine();
			return str;
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
}
